//
//  HomeClassifyMusicCell.m
//  SleepingElf
//
//  Created by karong on 2023/10/12.
//

#import "HomeClassifyMusicCell.h"
#import "NSString+Number.h"
#import "UIButton+ImageAlign.h"

@interface HomeClassifyMusicCell ()
@property (weak, nonatomic) IBOutlet UIButton *viewBtn;
@property (weak, nonatomic) IBOutlet UIImageView *imageView;
@end

@implementation HomeClassifyMusicCell

- (void)awakeFromNib {
    [super awakeFromNib];
}

- (void)setDataWithObject:(MusicModel *)object {
    [super setDataWithObject:object];
    [[SDWebImageManager sharedManager] loadImageWithURL:[NSURL URLWithString:object.cover] options:0 progress:^(NSInteger receivedSize, NSInteger expectedSize, NSURL * _Nullable targetURL) {
        } completed:^(UIImage * _Nullable image, NSData * _Nullable data, NSError * _Nullable error, SDImageCacheType cacheType, BOOL finished, NSURL * _Nullable imageURL) {
            if (image) {
                image = [image imageWithRenderingMode:(UIImageRenderingModeAlwaysTemplate)];
                self.imageView.image = image;
                self.imageView.tintColor = [UIColor colorFromHexRGB:@"ffffff"];
            }
        }];
    [self.viewBtn setTitle:SESF(WSLocalized(@"%@人播放"), [NSString gr10Thousands1DecimalWithValue:object.views]) forState:(UIControlStateNormal)];
    [self.viewBtn setButtonImageTitleStyle:(GRButtonImageTitleStyleLeft) padding:4];
}


@end
